package com.nb.pojo;

public class Student {
    private int no;
    private String name;
    private String address;
    private School school;

    public void setNo(int no) {
        this.no = no;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public void setSchool(School school) {
        this.school = school;
    }

    public void shout(String test){
        System.out.println(test);
    }
    /*重写hashCode和equals时，当判断一个对象是否属于同一个对象
      会先判断hashCOde是否一样，如果一样，再判断equals是否一样，如果都一样，则为同一个对象
    **/
    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + no;
        return result;
    }
    @Override
    public boolean equals(Object obj) {
        if (this == obj)return true;
        if (obj == null)return false;
        if (getClass() != obj.getClass())return false;
        Student student = (Student) obj;
        if (this.no != student.no)return false;
        return true;
    }

    @Override
    public String toString() {
        return "Student{" +
                "no=" + no +
                ", name='" + name + '\'' +
                ", address='" + address + '\'' +
                ", school=" + school +
                '}';
    }
}
